|
|
|
|
|
|
|
Figure 9.4
Tweening with endpoint interpolation. |
|
|
|
|
|
|
|
|
with the number of frames in the animation. Then for each frame, it should contain the number of polylines making up the frame. |
|
|
|
|
|
|
|
|
Each polyline consists of a number of points that should be connected to form a continuous series of line segments. For each polyline in each frame, the file must contain the number of points in the polyline followed by the coordinates of the points themselves. |
|
|
|
|
|
|
|
|
For example, the file Square.twe, which is located in the Ch9 directory on the CD-ROM, defines two frames. Each frame shows a square consisting of a single polyline made up of five points. The comments to the right have been added to make the following listing easier to understand and are not part of the file. |
|
|
|
 |
|
|
|
|
2 ' 2 frames in the animation. 1 ' 1 polyline in the first frame. 5 ' 5 points in the polyline. 50, 50 ' Point data. 50, 150
150, 150
150, 50
50, 50
1 ' 1 polyline in the second frame. 5 ' 5 points in the polyline. 50, 150 ' Point data. 150, 150
150, 50
50, 50
50, 150 |
|
|
|
|
|
|
|
|
Endpoint interpolation is relatively simple and fast. It also ensures that segments that share an endpoint in the key frames share an endpoint in the tweens, too. Unfortunately, it can also distort the image. As you can see in Figure 9.4, the segment in the middle tween is significantly shorter than those in the key frames. |
|
|
|
|
|
|
|
|
In some animations, this distortion may not be noticeable. The file Smile.twe defines three frames showing a sad face turning happy. Run the TweenEnd program and load this file. Create five tweens between the key frames and run the animation once at 20 frames per second. The endpoint interpolation introduces some distortion in the tweens. The curves in the key frames do not have the same shape, however, so the changes between key frames are distortions as well. Any distortion introduced by the tweens is lost in the larger distortion between the key frames, and the animation appears smooth. |
|
|
|
|
|